package com.dong.jdk8.repeatable;

import java.lang.annotation.*;
import java.util.Arrays;

/**
 * Created by jianyang206881 on 2017/9/25.
 */
public class RepeatingAnnotations {
    @Target( ElementType.TYPE )
    @Retention( RetentionPolicy.RUNTIME )
    public @interface Filters {
        Filter[] value();
    }

    @Target( ElementType.TYPE )
    @Retention( RetentionPolicy.RUNTIME )
    @Repeatable( Filters.class )// 重复注解
    public @interface Filter {
        String value();
    };

    // 重复注解
    @Filter( value = "filter1" )
    @Filter( "filter2" )
    public interface Filterable {
    }

    @Filters({@Filter("aaa"), @Filter("bbb"), @Filter("ccc")})
    public interface Filtersable {

    }

    public static void main(String[] args) {
        for( Filter filter: Filterable.class.getAnnotationsByType( Filter.class ) ) {
            System.out.println( filter.value() );
        }
    }
}
